<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <title>软件学院操行管理系统</title>
    <!-- The styles -->
    <link href="css/bootstrap-cerulean.css" rel="stylesheet">
    <link href="css/login.css" rel="stylesheet">
    <link href="css/charisma-app.css" rel="stylesheet">
    <style type="text/css">
        body {
            padding-bottom: 40px;
        }

        .sidebar-nav {
            padding: 9px 0;
        }
    </style>
    <script src="http://lib.sinaapp.com/js/jquery/2.2.4/jquery-2.2.4.min.js"></script>
    <script src="js/bootstrap-dropdown.js"></script>
    <script src="js/common/public.js"></script>
    <script src="js/base64.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            //Ajax调用处理
            var urlMsg = parseUrl(window.location.search);

            var html = $.ajax({
                type: "GET",
                url: "http://localhost:1066/student/findHistoryScore?token=" + urlMsg.token + "&term=" + urlMsg.term,
                async: false
            }).responseText;
            var result = eval('(' + html + ')');
            if (result.code != 200) {
                alert(result.msg)
            } else {
                $("#name").html(result.data.name);
                $("#studentName").html(result.data.name);

                var score = result.data.score;
                if (score >= 140) {
                    $("#score").html(result.data.score).css("color", "#F1FA28");
                } else if (score >= 120) {
                    $("#score").html(result.data.score).css("color", "#EB681E");
                } else if (score >= 100) {
                    $("#score").html(result.data.score).css("color", "#EB1ED2");
                } else if (score >= 90) {
                    $("#score").html(result.data.score).css("color", "#37EB1F");
                } else if (score >= 80) {
                    $("#score").html(result.data.score).css("color", "#1F99EB");
                } else if (score >= 70) {
                    $("#score").html(result.data.score).css("color", "#AF8F8F");
                } else {
                    $("#score").html(result.data.score).css("color", "#C42E2E");
                }

                if (result.data.historyScore == null) {
                    $("#studentScoreDetaile tbody").append("<tr><td colspan='4' style='text-align:center;font-size:20px;color:red;'><br>很遗憾，你没有任何操行记录！<br><br></td></tr>");
                } else {
                    for (index in result.data.historyScore) {
                        addStudentScoreTable(result.data.historyScore[index].finallyScore,
                            result.data.historyScore[index].reason,
                            result.data.historyScore[index].remark,
                            result.data.historyScore[index].page,
                            result.data.historyScore[index].operateDate.substring(0,10))
                    }
                }

                $("#currentTerm").html("当前学年："+result.data.term.substring(0,9)+"第"+result.data.term.substring(10,11)+"学期"
                );

            }

        })

        function addStudentScoreTable(score, reason, remark, page,date) {
            if (score > 0) {
                $("#studentScoreDetaile tbody").append("<tr><td class='center' style='color:green; font-size:20px;text-align:center;'>" + score + "</td>" +
                    "<td class='center' style='font-size:15px;'>" + reason + "</td>" +
                    "<td class='center' style='font-size:15px;'>" + remark + "</td>" +
                    "<td class='center' style='font-size:15px;'>" + page + "</td>" +
                    " <td class='center' style='font-size:15px;'>" + date + "</td></tr>");
            } else {
                $("#studentScoreDetaile tbody").append("<tr><td class='center' style='color:red; font-size:20px;text-align:center;'>" + score + "</td>" +
                    "<td class='center' style='font-size:15px;'>" + reason + "</td>" +
                    "<td class='center' style='font-size:15px;'>" + remark + "</td>" +
                    "<td class='center' style='font-size:15px;'>" + page + "</td>" +
                    " <td class='center' style='font-size:15px;'>" + date + "</td></tr>");
            }
        }


        function toChangePassword() {
            var studentNumber = $("#studentNumber").val();
            var urlMsg = parseUrl(window.location.search);
            var token = decode(urlMsg.token);
            window.location.href = "changePassword.html?studentNumber=" + studentNumber + "&token=" + token;
        }

        function logout() {
            var urlMsg = parseUrl(window.location.search);
            var token = decode(urlMsg.token);
            var html = $.ajax({
                type: "POST",
                url: "http://localhost:1066/student/logout?token=" + token,
                async: false
            }).responseText;
            var result = eval('(' + html + ')');
            if (result.code == 200) {
                alert(result.msg)
                window.location.href = "login.html"
            }
        }

        function findHistory() {
            var urlMsg = parseUrl(window.location.search);
            window.location.href = "findHistory.html?token=" + urlMsg.token;
        }
        function goIndex() {
            var urlMsg = parseUrl(window.location.search);
            var token = encode(urlMsg.token);

            window.location.href = "index.html?token=" + token;
        }
    </script>
</head>

<body style="width:auto">

<div class="navbar">
    <div class="navbar-inner">
        <div class="container-fluid">
            <a class="btn btn-navbar" data-toggle="collapse"
               data-target=".top-nav.nav-collapse,.sidebar-nav.nav-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </a>
            <a class="brand" href="javascript:goIndex()"> <img src="images/logo20.png"/> <span>软件学院操行管理系统</span></a>
            <a class="brand" href="javascript:findHistory()"> <span>查询历史分数</span></a>
            <div class="btn-group pull-right">
                <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
                    <i class="icon-user"></i>
                    <span class="hidden-phone" id="studentName"></span>
                    <span class="caret"></span>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="javascript:toChangePassword()">修改密码</a></li>
                    <li class="divider"></li>
                    <li><a href="javascript:logout()">安全退出</a></li>
                </ul>
            </div>

        </div>
    </div>
</div>

<div class="container-fluid">
    <div class="row-fluid">
        <div id="content" class="span10" style="width: 78.5%; margin-left: 11%;padding-top:20px;">
            <div class="row-fluid sortable">
                <div class="box span9">
                    <div class="box-header well" data-original-title>
                        <h2>我的操行分&nbsp;&nbsp;&nbsp;&nbsp;</h2>
                        <h2 id="currentTerm"></h2>
                    </div>
                    <div class="box-content">
                        <div class="page-header">
                            <h1 style="font-size:50px;padding-left:100px;">欢迎你：</h1>
                        </div>
                        <div class="row-fluid" style="padding-top: 30px; text-align: center; ">
                            <h1 id="name" style="font-size:70px; letter-spacing: 50px;"></h1>
                            <input type="hidden" value="" id="studentNumber"/>
                            <input type="hidden" value="" id="studentId"/>
                        </div>

                        <div class="row-fluid">
                            <br><br><br><br><br><br>

                            <div class="center">
                                <h1 id="score"
                                    style="padding-left:50px;padding-right:50px;text-align: center;display: inline-block; color:#EB681E;font-size:170px;">
                                    100</h1>
                            </div>
                        </div>

                        <br>

                        <div class="divider-content">
                            <span></span>
                        </div>

                        <br>
                        <br>
                        <br>

                        <!-- start dispaly studentscore detail -->
                        <div class="row-fluid">
                            <h1 style="font-size:30px;padding-left:100px;">操行详情：</h1>
                            <br>
                            <br>
                            <table id="studentScoreDetaile"
                                   class="table table-striped table-bordered bootstrap-datatable">
                                <thead>
                                <tr>
                                    <th class="sorting" style="width: 10%; text-align:center;">分值</th>
                                    <th class="sorting" style="width: 30%;">原因</th>
                                    <th class="sorting" style="width: 10%;">部门</th>
                                    <th class="sorting" style="width: 10%;">页码</th>
                                    <th class="sorting" style="width: 15%;">时间</th>
                                </tr>
                                </thead>
                                <tbody>


                                </tbody>
                            </table>
                        </div>
                        <!-- dispaly studentscore detail end-->
                        <br>
                        <br>
                        <br>

                        <!-- start dispaly classscore detail -->

                    </div>
                </div>


            </div>
        </div>
    </div>
    <hr>
    <div id="footer">
        <p style="padding-top:0px; text-align:center; display:block">
            版本所有:<a href="javascript:void(0)">南阳理工软件学院</a>&nbsp;&nbsp;&nbsp;技术支持:<a href="javascript:void(0)">前研工作室</a>
        </p>
    </div>

</div>
</body>
</html>
